1. Technical Field
The present disclosure relates to a dynamic code compiling device, in particular, to a hybrid dynamic code compiling device, a hybrid dynamic code compiling method, and a service system thereof.
2. Description of Related Art
Currently, the network and electronic technology develops rapidly, and by using a terminal device, people can easily browse the web page easily to obtain required service and information. The content of the web page can be edited by text markup language, such as hyper text markup language (HTML), so as to show the structured information (such as title, paragraph, and list table).
However, the text markup language is usually used to edit static or non-interactive web page, but hardly used to edit the dynamic or interactive web page. Thus, a dynamic directly compiling program language is provided, such as JavaScript®. JavaScript® is a dynamic, weak prototype, and prototype based language which can support built-in prototype. JavaScript® code can be embedded in the HTML web page, and can be written in a single file which has the auxiliary file name of “js”, so as to easily achieve separation of structure and behavior. JavaScript® code can be used to embed the dynamic script in the HTML web page, response the browser event, access the element of the HTML web page, verify data before the data is sent to the server, detect browser information of the guest, or control cookies.
Currently, Mozilla® provides an optimization solution for JavaScript®, the content of a pre-defined file, named as “ASM.js”, is compared with the received JavaScript® code, so as to convert the received JavaScript® code to C/C++ code through a low level virtual machine (LLVM). Therefore, the terminal device (such as the electronic device with iOs®, Windows®, or Android® system) can execute the C/C++ code to display the dynamic or interactive web page. However, when the received JavaScript® code does not exist in codebase of the pre-defined file, named as “ASM.js”, the received JavaScript® code cannot be converted to the C/C++ code. That is, the optimization solution for JavaScript® provided by Mozilla® lacks of flexibility.
Furthermore, Google® provides a JavaScript® engine, called by V8 engine. Before the JavaScript® code is executed, the V8 engine does not direct compile the JavaScript® code, and does not compile the JavaScript® code to the byte code, but compiles the JavaScript® code to a machine code to increase the performance. However, the V8 engine still cannot avoid the time consumption for loading the JavaScript® code. In addition, the JavaScript® code itself cannot control the release of the memory space, and the memory leak may occur. Thus, the V8 engine is designed to have a garbage collection (GC) function.
The garbage collection is an automatic memory management mechanism. When the data of variables, objects, or strings stored in the dynamic memory is useless, the garbage collection is used to release the memory space occupied by the data. The garbage collection of different strategy can be stop-the-world (STW) garbage collection, concurrent garbage collection, or incremental garbage collection. When the system determines the garbage collection to be executed, the stop-the-world garbage collection stops executing the current program, and begins to execute the garbage collection. The concurrent garbage collection executes the garbage collection without stopping the program execution, but can merely execute the uncomplicated garbage collection by contrast, thus causing poor performance. The incremental garbage collection adopts the stop-the-world garbage collection and the concurrent garbage collection, and determines tradeoff of both of the stop-the-world garbage collection and the concurrent garbage collection. Thus, the incremental garbage collection usually executes uncomplicated garbage collection as the concurrent garbage collection, but when the system determines the complicated garbage collection to be executed, as the stop-the-world garbage collection, the incremental garbage collection stops executing the current program, and begins to execute the complicated garbage collection.
It is known that the stop-the-world garbage collection and the incremental garbage collection cannot be controlled externally, and the concurrent garbage collection may cause the poor performance. V8 engine currently adopts the incremental garbage collection to reduce the impact of the executing program interruption. However, when incremental garbage collection executes stop-the-world garbage collection, incremental garbage collection still cannot be controlled externally, and the executing program still may be stopped at unexpected time, thus causing the poor user experience.